home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / croutes.zip / PAUSE.C < prev    next >
Text File  |  1984-05-17  |  2KB  |  46 lines

  1. /*                             *** pause.c ***                       */
  2. /*                                                                   */
  3. /* IBM-PC microsoft "C" under PC-DOS                                 */
  4. /*                                                                   */
  5. /* Function to cause a program to appear to pause for a given period */
  6. /* time.  Uses the system clock for timing.  Accurate to 1/100's of  */
  7. /* a second.                                                         */
  8. /*                                                                   */
  9. /* Written by L. Cuthbertson, May 1984.                              */
  10. /*                                                                   */
  11. /*********************************************************************/
  12. /*                                                                   */
  13.  
  14. pause(seconds)
  15. float seconds;            /* number of seconds to pause */
  16. {
  17.     int ih,im,is,iths;
  18.     long current,offset,diff;
  19.  
  20.     /* determine the current time */
  21.     dostime(&ih,&im,&is,&iths);
  22.  
  23.     /* calculate the current time in 1/100's of a second */
  24.     offset = (ih*360000) + (im*6000) + (is*100) + iths;
  25.     current = offset;
  26.  
  27.     /* calculate the number of 1/100's of a second to pause */
  28.     diff = seconds*100;
  29.     if (diff > 8640000) {        /* maximum of 1 day pause */
  30.         return(-1);
  31.     }
  32.  
  33.     /* keep on polling the clock until difference has elapsed */
  34.     while ((current-offset) < diff) {
  35.         dostime(&ih,&im,&is,&iths);
  36.         current = (ih*360000) + (im*6000) + (is*100) + iths;
  37.         if (current < offset) {        /* spans midnight */
  38.             current += 8640000;
  39.         }
  40.     }
  41.  
  42.     /* done */
  43.     return(0);
  44.  
  45. }
  46.